package com.cnt.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cnt.entity.DonationRecords;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DonationRecordsDao extends BaseMapper<DonationRecords> {

    @Select("select * from donation_records where donation_id = #{donationId}")
    public List<DonationRecords> getByDonationId(Integer donationId);

    @Select("select * from donation_records where user_id = #{id}")
    public List<DonationRecords> getByUserId(Integer id);

    @Select("SELECT * FROM donation_records WHERE YEAR(donation_time) = #{year} ")
    public List<DonationRecords> selectByYear(@Param("year") int year);

    @Select("SELECT * FROM donation_records WHERE YEAR(donation_time) = #{year} AND MONTH(donation_time) = #{month}")
    public List<DonationRecords> selectByYearAndMonth(@Param("year") int year, @Param("month") int month);
}
